package com.appspot.bibtable.model.format;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.logging.Logger;

import com.appspot.bibtable.util.StringUtility;

public class YearParser extends InputParser
{
	private static final SimpleDateFormat internalParser = new SimpleDateFormat("yyyy");

	@Override
	public Object parse(String value)
	{
		if (StringUtility.isNullOrEmpty(value))
		{
			return null;
		}

		Date date = null;
		try
		{
			date = internalParser.parse(value);
		}
		catch (ParseException ex)
		{
			Logger.getLogger(YearParser.class.getName()).warning("Invalid format date.");
		}
		return date;
	}
}
